//
// Created by YE on 2024/2/13.
//

#ifndef MATINTERPRETER_YCH_MAT_H
#define MATINTERPRETER_YCH_MAT_H

#include "pthread.h"
#include "limits.h"
#include "stdlib.h"


#if defined(LLONG_MAX)
typedef double Float;
#else
typedef float Float;
#endif
typedef struct YMat {
    int rows, cols;
    Float **values;
    unsigned char is_popp;
} YMat, Mat;

void initMat(Mat *mat, int m, int n);

void *createMat(int m, int n);

void *copyMat(Mat *mat);

Float **mallocMat(int m, int n);

void freeMat(Mat *mat);

void deleteMat(Mat *mat);

void matAdd(Float **matT, Float **matA, Float **matB, const int ROWS, const int COLS);

void matSub(Float **matT, Float **matA, Float **matB, const int ROWS, const int COLS);

void matMul(Float **matT, Float **matA, Float f, const int ROWS, const int COLS);

void matDiv(Float **matT, Float **matA, Float f, const int ROWS, const int COLS);

void matInner(Float **matT, Float **matA, Float **matB, const int ROWS, const int COLS,
              const int ICOLS);

typedef struct {
    Float **matT;
    Float **matA;
    Float **matB;
    int start_row;
    int start_col;
    int end_row;
    int end_col;
    int k;
} MatParameters;

void matInnerThread(Float **matT, Float **matA, Float **matB, const int ROWS, const int COLS,
                    const int ICOLS);

int matEq(Float **matA, Float **matB, const int ROWS, const int COLS);

void matPow(Float **matT, Float **matA, unsigned int n, const int N);

#endif //MATINTERPRETER_YCH_MAT_H
